const app = getApp();
Page({
  data: {
    cndUrl: app.domainName,
    swiperA:[1,2,3,4,5,6,7,   1,2,3,4,5],
    swiperB:[1,2,3,4,5,6,7],
    current:0,
    fileId:1,
    lastSlideIndex:0,
    isX:'x',
    isTop:0,
    s2Top:136,
    isShot:{a:'',b:'hide'},
    showAB:{a:'fadeIn2 animated',b:'hide'}, //test
    scrollLeft: 0,
    sideActive:['ave','','','','','','','',''],
    sideClick:false,
    longHeight:200,
    isread:{1:'2',2:'1',3:'1',4:'1',5:'1',6:'1',7:'1'},
    islang:{zh:'',en:'hide'},
    curLang:'zh',
    initAni:{a:'fadeInDown2 animated dy5',b:'fadeInLeft animated dy1'}
  },
  onLoad: function (options) {
     var that=this;
      setTimeout(function(){
        //that.setData({scrollLeft:169*2});
      }, 4000);
      console.log(app.screenHeight);
      if(app.screenHeight <  1350){
        that.setData({isX:''});
      }
      var _cha= app.screenHeight - 1520;
      if(_cha > 0){
        that.setData({isTop:_cha/2});
      }
      var _longHeight= app.screenHeight - 930;
      if(_longHeight < 100){_longHeight:100;}
      that.setData({longHeight:_longHeight});

      wx.request({
        url: app.domainName + 'web/?c=getread',
        method: 'POST',
        data: {op:app.globalData.openid
        }, header: { 'content-type': 'application/x-www-form-urlencoded' },
        success: function (res) { 
          console.log(res.data.s);
            if(1 == res.data.s){
              var _isread=that.data.isread;
              console.log(res.data.d);
              for(var _id in res.data.d){
                _isread[res.data.d[_id]]=2;
              }
              that.setData({isread:_isread});
            }
         }});

         this.setTong('线上展览In', 'in_zhanlan');
         getApp().mtj.trackEvent('in_zhanlan');
  },
  changlang: function(e){
     var _curLang=this.data.curLang;
     console.log(_curLang)
     
     this.setData({initAni:{a:'',b:''}});
     if('zh' == _curLang){
      this.setData({curLang:'en',  islang:{zh:'hide',en:''}});
     }else{
      this.setData({curLang:'zh', islang:{zh:'',en:'hide'}});
     }
  },
  showB:function(e){
    this.setData({showAB:{a:'hide',b:'fadeIn animated'}});
    this.setTong('进入展览', 'go_zhanting');
    getApp().mtj.trackEvent('go_zhanting');
  },
  showmore:function(e){
    this.setData({isShot:{a:'hide',b:''}});
  },
  changS1: function(e){
      var _current=e.detail.current;
      var _lastSlideIndex=this.data.lastSlideIndex;
      var _sideClick=this.data.sideClick;
      var _isread=this.data.isread;
      _isread[_current+1]=2;
      this.setData({isread:_isread});
      this.setData({fileId:(_current+1)});
      if(false == _sideClick){
          if(_current > _lastSlideIndex){
            if(4 == _current){
              this.setData({scrollLeft:169*1});
            }
            if(5 == _current){
              this.setData({scrollLeft:169*2});
            }
            if(6 == _current){
              this.setData({scrollLeft:169*3});
            }
        }else{
          if(2 == _current){
            this.setData({scrollLeft:169*2});
          }
          if(1 == _current){
            this.setData({scrollLeft:169});
          }
          if(0 == _current){
            this.setData({scrollLeft:0});
          }
        }

      }
      var _sideActive=['','','','','','','','',''];
       _sideActive[_current]='ave';
  
       this.setData({sideActive:_sideActive,current:_current,lastSlideIndex:_current,  sideClick: false, isShot:{a:'',b:'hide'}});

       wx.request({
        url: app.domainName + 'web/?c=setread',
        method: 'POST',
        data: {op:app.globalData.openid,id:_current
        }, header: { 'content-type': 'application/x-www-form-urlencoded' },
        success: function (res) { 

         }});


  },
  setclick:function(e){
     var _id=e.currentTarget.dataset.id;
     
     this.setData({current:_id, sideClick: true});
  },
  gonext: function(e){
    var _id=this.data.current;
    var _num=_id+1;
    if(_num > 6){_num=0}
    console.log(_num);
    this.setData({current:_num});
},
gopre: function(e){
  var _id=this.data.current;
  var _num=_id-1;
  if(_num < 0){_num=6;}
  this.setData({current:_num});
},
setTong(_id,_name){
  wx.request({
    url: app.domainName + 'web/?c=bai',
    method: 'POST',
    data: {op:app.globalData.openid, id:_id,name:_name
    }, header: { 'content-type': 'application/x-www-form-urlencoded' },
    success: function (res) {  }
  });
},
  onShareAppMessage: function (e) {
    var _imgUrl=app.domainName+'img/65.png';
    this.setTong('分享朋友圈', 'onlineview');
    getApp().mtj.trackEvent('home_share');
      return {
        title: '【没有谁是一座孤岛】保时捷公共艺术疗愈展览',
        imageUrl:_imgUrl,
        path: '/pages/index/index'
      }
}
})